package cn.com.wxd.wechat.common.util.xml;

import java.io.Writer;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
import com.thoughtworks.xstream.io.xml.XppDriver;
import com.thoughtworks.xstream.security.NullPermission;
import com.thoughtworks.xstream.security.PrimitiveTypePermission;


/**
 * Title:XStreamInstance.java
 * Description:cn.com.wxd.wechat.common.util.xml
 * 
 * Company: wxd网站系统
 * Copyright: Copyright (c) 2015
 * All right reserved.
 * Created time: 2016-8-23 下午5:25:58
 *
 * @author WangXuDong
 * @version 1.0
 */
public class XStreamInit {
	public static XStream getInstance() {
		XStream xstream = new XStream(new DomDriver());
		return xstream;
//				new XppDriver() {
//			public PrettyPrintWriter createWriter(Writer out) {
//				return new com.thoughtworks.xstream.io.xml.PrettyPrintWriter(out, getNameCoder()) {
//					protected String PREFIX_CDATA = "<![CDATA[";
//					protected String SUFFIX_CDATA = "]]>";
//					protected String PREFIX_MEDIA_ID = "<MediaId>";
//					protected String SUFFIX_MEDIA_ID = "</MediaId>";
//
//					protected void writeText(com.thoughtworks.xstream.core.util.QuickWriter writer, String text) {
//						if (text.startsWith(PREFIX_CDATA) && text.endsWith(SUFFIX_CDATA)) {
//							writer.write(text);
//						} else if (text.startsWith(PREFIX_MEDIA_ID) && text.endsWith(SUFFIX_MEDIA_ID)) {
//							writer.write(text);
//						} else {
//							super.writeText(writer, text);
//						}
//
//					}
//				};
//			}
//		});
//		xstream.ignoreUnknownElements();
//		xstream.setMode(XStream.NO_REFERENCES);
//		xstream.addPermission(NullPermission.NULL);
//		xstream.addPermission(PrimitiveTypePermission.PRIMITIVES);
//		return xstream;
	}

}
